class Solution:
    word = [
        [],
        [],
        ['a', 'b', 'c'],
        ['d', 'e', 'f'],
        ['g', 'h', 'i'],
        ['j', 'k', 'l'],
        ['m', 'n', 'o'],
        ['p', 'q', 'r', 's'],
        ['t', 'u', 'v'],
        ['w', 'x', 'y', 'z'],
    ]

    def letterCombinations(self, digits: str) -> list[str]:
        if len(digits) == 0:
            return []

        res_1 = ['']
        res_2 = []

        for i in range(len(digits)):
            if i & 1:
                res_1.clear()
                for j in res_2:
                    for k in Solution.word[int(digits[i])]:
                        res_1.append(j + k)
            else:
                res_2.clear()
                for j in res_1:
                    for k in Solution.word[int(digits[i])]:
                        res_2.append(j + k)

        if len(digits) & 1 == 0:
            return res_1
        else:
            return res_2